obtain_information = "辽宁"
result_data = []

with open(r"E:\dddownload\Python\step01_语法基础&内置对象\object\object_07_FilesDemo.txt", "r", encoding="utf-8") as f:
    content = f.readlines()
    for i in content:
        line = i.strip()  # 去掉换行符和空格
        if obtain_information in line:
            data = line.split(" ")
            dict_data = {
                "name": data[0],
                "地址": " ".join(data[1:-1]),
                "邮编": data[-1]
            }
            result_data.append(dict_data)

print(result_data)  # 调试用
with open(r"E:\dddownload\Python\xxxx.txt", "w", encoding="utf-8") as f:
    f.write(str(result_data))
